{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Chap2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-28T03:37:30.396364Z",
     "start_time": "2019-03-28T03:37:30.231Z"
    }
   },
   "outputs": [],
   "source": [
    "library(ggplot2)\n",
    "# set the path\n",
    "setwd(getwd())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Fig2-6[Histogram]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-28T03:43:11.242990Z",
     "start_time": "2019-03-28T03:43:11.178Z"
    }
   },
   "outputs": [],
   "source": [
    "# load data\n",
    "# 仅有一列数据，选取此列,从data.frame转化为vector\n",
    "loans_income <- read.csv(\"../psds_data/loans_income.csv\")[, 1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-28T03:43:11.605220Z",
     "start_time": "2019-03-28T03:43:11.584Z"
    }
   },
   "outputs": [],
   "source": [
    "# take a somple random sample\n",
    "samp_data <- data.frame(income=sample(loans_income, 1000),\n",
    "                       type = 'data_dist')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-28T03:48:30.659478Z",
     "start_time": "2019-03-28T03:48:30.605Z"
    }
   },
   "outputs": [],
   "source": [
    "# take s sample of means of 5 values\n",
    "sample_mean_05 <- data.frame(\n",
    "    income = tapply(sample(loans_income, 1000*5), rep(1:1000, rep(5, 1000)),FUN=mean),\n",
    "    type = 'mean_of_5'\n",
    ")\n",
    "\n",
    "# take s sample of means of 20 values\n",
    "sample_mean_20 <- data.frame(\n",
    "    income = tapply(sample(loans_income, 1000*20), rep(1:1000, rep(20, 1000)),FUN=mean),\n",
    "    type = 'mean_of_20'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-28T03:51:27.957963Z",
     "start_time": "2019-03-28T03:51:27.911Z"
    }
   },
   "outputs": [],
   "source": [
    "# bind the data.frames and convert type to a factor\n",
    "income <- rbind(samp_data, sample_mean_05, sample_mean_20)\n",
    "income$type <- factor(\n",
    "    income$type, \n",
    "    levels = c('data_dist', 'mean_of_5', 'mean_of_20'),\n",
    "    labels = c('Data', 'Mean of 5', 'Mean of 20')\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-28T03:53:03.395120Z",
     "start_time": "2019-03-28T03:53:02.942Z"
    }
   },
   "outputs": [
    {
     "data": {},
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlgAAAJYCAMAAACJuGjuAAAC01BMVEUAAAABAQEDAwMEBAQJ\nCQkKCgoMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxsc\nHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0u\nLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk7Ozs8PDw9PT0+Pj4/Pz9AQEBB\nQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJT\nU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZGRl\nZWVmZmZnZ2doaGhpaWlqampra2tsbGxtbW1ubm5vb29xcXFycnJzc3N0dHR1dXV2dnZ3d3d4\neHh5eXl6enp7e3t8fHx9fX1+fn5/f3+BgYGCgoKDg4OEhISFhYWGhoaIiIiJiYmKioqLi4uM\njIyOjo6Pj4+QkJCRkZGSkpK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      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot the histogram\n",
    "ggplot(income, aes(x=income))+\n",
    "    geom_histogram(bins = 40)+\n",
    "    facet_grid(type~.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "R 3.4",
   "language": "R",
   "name": "ir34"
  },
  "language_info": {
   "codemirror_mode": "r",
   "file_extension": ".r",
   "mimetype": "text/x-r-source",
   "name": "R",
   "pygments_lexer": "r",
   "version": "3.4.4"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
